<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>骨医快线</title>
	<link href="../../css/mui.plus.css" rel="stylesheet" />				
	<style type="text/css">
		header  .mui-btn.mui-btn-link {
			color: #fff;
		}
	</style>
</head>
<body>
	<header class="mui-bar mui-bar-nav oe-pri-bar">
	    <a class="mui-action-back mui-btn mui-btn-link mui-pull-left">取消</a>
	    <h1 class="mui-title">备忘录</h1>
	    <a id="btn-commit" class="mui-btn mui-btn-link mui-pull-right">保存</a>
	</header>
	
	<div class="mui-content">
	    <textarea id="txt-memo" name="" rows="20" cols="" placeholder="请输入"></textarea>
	</div>
	
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/app.js"></script>
	<script src="../../js/lib/template.js"></script>
	<script type="text/javascript">
		(function($, a){
			var wv,
				html,
				tmpData,
				commitData = {};
				
			var memoTxt = document.getElementById("txt-memo");
				
			$('body').on('tap', '#btn-commit', function(){
				commitData.rec_memo = memoTxt.value;
				
				a.net.post('c_med_record/update', commitData, function(data){
					if(data && data.code === '100'){
						$.toast('保存成功');
						$.oldBack();
					}
				});
			});
			
			$.plusReady(function(){
				wv = plus.webview.currentWebview();
				commitData.rec_id = wv.rec_id;
				
				getMedicalRecord(commitData.rec_id);
			});
			
			var getMedicalRecord = function(medId){
				a.net.get('c_med_record/show', {rec_id : medId}, function(data){
					if(data && data.code === '100' && data.data.rec_memo){
						memoTxt.value = data.data.rec_memo;
					}
				});
			}
			
			$.oldBack = $.back;
			$.back = function(){
				$.confirm('该备忘录尚未保存，是否退出？', '骨医快线', ['确定', '取消'], function(e){
					if(e.index === 0) $.oldBack();
				});
			}
		}(mui, app));
	</script>
</body>
</html>